//
//  CellForColumn2.m
//  MY Project For Sport
//
//  Created by dllo on 16/3/3.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForColumn2.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import <DKNightVersion.h>
#import "ModelForColumn2.h"
#import "UIColor+Wonderful.h"
#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667

@interface CellForColumn2 ()

@property (nonatomic, retain) UILabel *content;
@property (nonatomic, retain) UIImageView *imageViewForHot;
@property (nonatomic, retain) UILabel *title;
@property (nonatomic, retain) UILabel *number;
@end

@implementation CellForColumn2

- (void)dealloc {
    
    [_imageViewForHot release];
    [_title release];
    [_content release];
    [_number release];
    [super dealloc];
    
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentView.dk_backgroundColorPicker = DKColorWithColors([UIColor linenColor], [UIColor grayColor]);

        [self createSubview];
        
    }
    return self;
    
}

- (void)createSubview {
    
    self.imageViewForHot = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewForHot];
    [_imageViewForHot release];
    
    
    self.title = [[UILabel alloc] init];
    [self.contentView addSubview:self.title];
    [_title release];
    
    self.content = [[UILabel alloc] init];
    [self.contentView addSubview:self.content];
    [_content release];
    
    self.number = [[UILabel alloc] init];
    [self.contentView addSubview:self.number];
    [_number release];
    
    
}
- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.imageViewForHot.frame = CGRectMake(5 * WEIGHTT, 5 * HEIGHTT, self.contentView.frame.size.width / 4, self.contentView.frame.size.height - 10 * HEIGHTT);
   //  self.imageViewForHot.backgroundColor = [UIColor redColor];
    
    self.title.numberOfLines = 0;
    self.title.font = [UIFont systemFontOfSize:18];
    self.title.frame = CGRectMake(self.contentView.frame.size.width / 4 + 10 * WEIGHTT, 5 * HEIGHTT, self.contentView.frame.size.width - self.contentView.frame.size.width / 4 - 15 * WEIGHTT , (self.contentView.frame.size.height - 15 * HEIGHTT) / 3);
    self.title.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
  //  self.title.backgroundColor = [UIColor orangeColor];
    
    self.content.font = [UIFont systemFontOfSize:13];
    self.content.textColor = [UIColor grayColor];
    self.content.numberOfLines = 0;
    self.content.frame = CGRectMake(self.contentView.frame.size.width / 4 + 10 * WEIGHTT, 10 * HEIGHTT+ (self.contentView.frame.size.height - 15) / 3, self.contentView.frame.size.width - self.contentView.frame.size.width / 4 - 15 * WEIGHTT , (self.contentView.frame.size.height - 15 * HEIGHTT) / 2.5);
  //  self.content.backgroundColor = [UIColor yellowColor];
    
    self.number.frame = CGRectMake(self.contentView.frame.size.width / 7 * 6, 10 * HEIGHTT+ (self.contentView.frame.size.height - 15) / 3 + (self.contentView.frame.size.height - 15 * HEIGHTT) / 2.5 + 5 * HEIGHTT , self.contentView.frame.size.width / 7 - 5 * WEIGHTT, (self.contentView.frame.size.height - 15 * HEIGHTT) / 4.3);
    self.number.textAlignment = NSTextAlignmentCenter;
    
    
}

-(void)passModelForHotNews:(ModelForColumn2 *)model {
    
    self.title.text = model.stitle;
    self.content.text = model.wapsummary;
    
   self.number.text = [NSString stringWithFormat:@"%ld", model.comment_total];
    self.number.text = [self.number.text stringByAppendingFormat:@"评"];
    
    [self.imageViewForHot sd_setImageWithURL:[NSURL URLWithString:[model.img objectForKey:@"u"]]];
    
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
